using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter23
{
	/// <summary>
	/// Example11: An Accelerated Electron
	/// An electron enters the region of a uniform electric
	/// field with v_i = 3.0 \times 10^6 m/s and E = 200 N/C.
	/// The horizontal length of the plates is l = 0.1 m.
	/// (A) Find the acceleration of the electron while it is
	/// in the electric field.
	/// a = -3.51 \time 10^{13} j m/s^2
	/// (B) If the electron enters the field at time t = 0, find
	/// the time at which it leaves the field.
	/// t = 3.33 \times 10^{-8} s
	/// (C) If the vertical position of the electron as it enters
	/// the field is y_i = 0, what is its vertical position
	/// when it leaves the field?
	/// y_f = -0.0195 m	
	/// </summary>
	public class Example11
	{
		public Example11()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.ElectricField E = new L.ElectricField();
			E.Y = 200.0;
			L.Velocity vi = new L.Velocity();
			vi.X = 3.0E6;
			L.Length l = new L.Length();
			l.m = 0.1;
		
			L.Force[] F = new L.Force[1];
			F[0] = new L.Force();
			F[0].Y = -L.Constant.ElementaryCharge*E.Y;
			L.TotalForce tf = new L.TotalForce(F);
			L.Mass m = new L.Mass();
			m.kg = L.Constant.ElectronMass;
			L.Acceleration a = new L.Acceleration(m,tf);
			//(A)
			result+=Convert.ToString(a.Y)+"\r\n";
			//(B)
			L.Time t = new L.Time();
			t.s = l.m/vi.mPERs;
			result+=Convert.ToString(t.s)+"\r\n";
			//(C)
			result+=Convert.ToString(0.5*a.Y*t.s*t.s)+"\r\n";
		}
	}
}
